package org.jeecg.modules.basesource.utils.cwbb;

import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import lombok.extern.slf4j.Slf4j;
import org.jeecg.common.util.DateUtils;
import org.jeecg.modules.basesource.entity.SbCwbbQykjzzybqyLrb;
import org.jeecg.modules.basesource.entity.SbCwbbQykjzzybqyXjllb;
import org.jeecg.modules.basesource.entity.SbCwbbQykjzzybqyZcfzb;
import org.jeecg.modules.dzswj.vo.response.cwbb.NsrxxForm;
import org.jeecg.modules.dzswj.vo.response.cwbb.YbqylrbGridlb;
import org.jeecg.modules.dzswj.vo.response.cwbb.YbqyxjllbGridlb;
import org.jeecg.modules.dzswj.vo.response.cwbb.YbqyzcfzbzbGridlb;

import java.text.ParseException;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;

/**
 * 企业会计准则(一般企业)包装类
 * @author chensherun on 2022/3/1.
 * @version 1.0
 */
@Slf4j
public class CwbbYbqyWrapperUtil {

    /**
     * 包装成利润表实体类
     * @param lrb
     * @param nsrForm
     * @param ybqylrbGridlbList
     */
    public static void wrapperQykjzzybqyLrb(SbCwbbQykjzzybqyLrb lrb, NsrxxForm nsrForm, List<YbqylrbGridlb> ybqylrbGridlbList) {
        Map<String, YbqylrbGridlb> ewbhxhMap = ybqylrbGridlbList.stream().collect(Collectors.toMap(YbqylrbGridlb::getEwbhxh, Function.identity(), (e1, e2) -> e2));
        if (nsrForm != null) {
            try {
                if (StringUtils.isNotBlank(nsrForm.getBsrq())) {
                    lrb.setBsrq(DateUtils.parseDate(nsrForm.getBsrq(), "yyyy-MM-dd"));
                }
            } catch (ParseException e) {
                log.error("日期转换有误:" + nsrForm.getBsrq());
            }
            lrb.setBbssq(nsrForm.getBbssq());
        }
        lrb.setSjcjSj(new Date());

        //一、营业收入_本期金额 1
        lrb.setYyysrBqje(getLrbBqje(ewbhxhMap, 1));
        lrb.setYyysrSqje1(getLrbSqje(ewbhxhMap, 1));
        //减：营业成本 2
        lrb.setJyycbBqje(getLrbBqje(ewbhxhMap, 2));
        lrb.setJyycbSqje1(getLrbSqje(ewbhxhMap, 2));
        //税金及附加 3
        lrb.setSjjfjBqje(getLrbBqje(ewbhxhMap, 3));
        lrb.setSjjfjSqje1(getLrbSqje(ewbhxhMap, 3));
        //销售费用 4
        lrb.setXsfyBqje(getLrbBqje(ewbhxhMap, 4));
        lrb.setXsfySqje1(getLrbSqje(ewbhxhMap, 4));
        //管理费用 5
        lrb.setGlfyBqje(getLrbBqje(ewbhxhMap, 5));
        lrb.setGlfySqje1(getLrbSqje(ewbhxhMap, 5));
        //财务费用6
        lrb.setCwfyBqje(getLrbBqje(ewbhxhMap, 6));
        lrb.setCwfySqje1(getLrbSqje(ewbhxhMap, 6));
        //资产减值损失（损失以“-”号填列） 7
        lrb.setZcjzssBqje(getLrbBqje(ewbhxhMap, 7));
        lrb.setZcjzssSqje1(getLrbSqje(ewbhxhMap, 7));
        //加：公允价值变动收益（损失以“-”号填列） 8
        //投资收益（损失以“-”号填列）9
        //其中：对联营企业和合营企业的投资收益
        //二、营业利润（亏损以“-”号填列） 11
        lrb.setEyylrksyhtlBqje(getLrbBqje(ewbhxhMap, 11));
        lrb.setEyylrksyhtlSqje1(getLrbSqje(ewbhxhMap, 11));
        //加：营业外收入 12
        lrb.setJyywsrBqje(getLrbBqje(ewbhxhMap, 12));
        lrb.setJyywsrSqje1(getLrbSqje(ewbhxhMap, 12));
        // 减：营业外支出 13
        lrb.setJyywzcBqje(getLrbBqje(ewbhxhMap, 13));
        lrb.setJyywzcSqje1(getLrbSqje(ewbhxhMap, 13));
        // 14
        // 三、利润总额（亏损总额以“-”号填列） 15
        lrb.setSlrzekszeyhtlBqje(getLrbBqje(ewbhxhMap, 15));
        lrb.setSlrzekszeyhtlSqje1(getLrbSqje(ewbhxhMap, 15));
        // 减:所得税费用 16
        lrb.setJsdsfyBqje(getLrbBqje(ewbhxhMap, 16));
        lrb.setJsdsfySqje1(getLrbSqje(ewbhxhMap, 16));
        // 四、净利润（净亏损以“-”号填列） 17
        lrb.setSjlrjksyhtlBqje(getLrbBqje(ewbhxhMap, 17));
        lrb.setSjlrjksyhtlSqje1(getLrbSqje(ewbhxhMap, 17));
        // 18
        // （一）基本每股收益 19
        lrb.setYjbmgsyBqje(getLrbBqje(ewbhxhMap, 19));
        lrb.setYjbmgsySqje1(getLrbSqje(ewbhxhMap, 19));
        // （二）稀释每股收益 20
        lrb.setExsmgsyBqje(getLrbBqje(ewbhxhMap, 20));
        lrb.setExsmgsySqje1(getLrbSqje(ewbhxhMap, 20));
        // 五、其他综合收益的税后净额 22
        lrb.setWqtzhsydshjeBqje(getLrbBqje(ewbhxhMap, 22));
        lrb.setWqtzhsydshjeSqje1(getLrbSqje(ewbhxhMap, 22));
        // （一）以后不能重分类进损益的其他综合收益 23
        lrb.setYyhbnzfljsydqtzhsyBqje(getLrbBqje(ewbhxhMap, 23));
        lrb.setYyhbnzfljsydqtzhsySqje1(getLrbSqje(ewbhxhMap, 23));
        // 1.重新计量设定受益计划变动额 24
        lrb.setZxjlsdsyjhbdeBqje(getLrbBqje(ewbhxhMap, 24));
        lrb.setZxjlsdsyjhbdeSqje1(getLrbSqje(ewbhxhMap, 24));
        // 2.权益法下不能转损益的其他综合收益 25
        lrb.setQyfxbnzsydqtzhsyBqje(getLrbBqje(ewbhxhMap, 25));
        lrb.setQyfxbnzsydqtzhsySqje1(getLrbSqje(ewbhxhMap, 25));
        // （二）将重分类进损益的其他综合收益 26
        lrb.setEjzfljsydqtzhsyBqje(getLrbBqje(ewbhxhMap, 26));
        lrb.setEjzfljsydqtzhsySqje1(getLrbSqje(ewbhxhMap, 26));
        // 1.权益法下可转损益的其他综合收益 27
        lrb.setQyfxkzsydqtzhsyBqje(getLrbBqje(ewbhxhMap, 27));
        lrb.setQyfxkzsydqtzhsySqje1(getLrbSqje(ewbhxhMap, 27));
        // 2.可供出售金融资产公允价值变动损益 28
        lrb.setKgcsjrzcgyjzbdsyBqje(getLrbBqje(ewbhxhMap, 28));
        lrb.setKgcsjrzcgyjzbdsySqje1(getLrbSqje(ewbhxhMap, 28));
        // 3.持有至到期投资重分类为可供出售金融资产损益 29
        lrb.setCyzdqtzzflwkgcsjrzcsyBqje(getLrbBqje(ewbhxhMap, 29));
        lrb.setCyzdqtzzflwkgcsjrzcsySqje1(getLrbSqje(ewbhxhMap, 29));
        // 4.现金流量套期损益的有效部分 30
        lrb.setXjlltqsydyxbfBqje(getLrbBqje(ewbhxhMap, 30));
        lrb.setXjlltqsydyxbfSqje1(getLrbSqje(ewbhxhMap, 30));
        // 5.外币财务报表折算差额 31
        lrb.setWbcwbbzsceBqje(getLrbBqje(ewbhxhMap, 31));
        lrb.setWbcwbbzsceSqje1(getLrbSqje(ewbhxhMap, 31));
        // 六、综合收益总额 32
        lrb.setLzhsyzeBqje(getLrbBqje(ewbhxhMap, 32));
        lrb.setLzhsyzeSqje1(getLrbSqje(ewbhxhMap, 32));
        // 资产处置收益（损失以“-”号填列） 33
        lrb.setZcczsyssyhtlBqje(getLrbBqje(ewbhxhMap, 33));
        lrb.setZcczsyssyhtlSqje1(getLrbSqje(ewbhxhMap, 33));
        // 34
        // （一）持续经营净利润（净亏损以“-”号填列） 35
        lrb.setYcxjyjlrjksyhtlBqje(getLrbBqje(ewbhxhMap, 35));
        lrb.setYcxjyjlrjksyhtlSqje1(getLrbSqje(ewbhxhMap, 35));
        // （二）终止经营净利润（净亏损以“-”号填列） 36
        lrb.setEzzjyjlrjksyhtlBqje(getLrbBqje(ewbhxhMap, 36));
        lrb.setEzzjyjlrjksyhtlSqje1(getLrbSqje(ewbhxhMap, 36));
        //  研发费用 37
        lrb.setYffyBqje(getLrbBqje(ewbhxhMap, 37));
        lrb.setYffySqje1(getLrbSqje(ewbhxhMap, 37));
        //  其中：利息费用 38
        lrb.setQzlxfyBqje(getLrbBqje(ewbhxhMap, 38));
        lrb.setQzlxfySqje1(getLrbSqje(ewbhxhMap, 38));
        //  利息收入  39
        lrb.setLxsrBqje(getLrbBqje(ewbhxhMap, 39));
        lrb.setLxsrSqje1(getLrbSqje(ewbhxhMap, 39));
        //  加：其他收益 40
        lrb.setJqtsyBqje(getLrbBqje(ewbhxhMap, 40));
        lrb.setJqtsySqje1(getLrbSqje(ewbhxhMap, 40));
        //  投资收益（损失以“-”号填列） 41
        lrb.setTzsyssyhtlBqje(getLrbBqje(ewbhxhMap, 41));
        lrb.setTzsyssyhtlSqje1(getLrbSqje(ewbhxhMap, 41));
        //  其中：对联营企业和合营企业的投资收益 42
        lrb.setQzdlyqyhhyqydtzsyBqje(getLrbBqje(ewbhxhMap, 42));
        lrb.setQzdlyqyhhyqydtzsySqje1(getLrbSqje(ewbhxhMap, 42));
        //  公允价值变动收益（损失以“-”号填列） 43
        lrb.setGyjzbdsyssyhtlBqje(getLrbBqje(ewbhxhMap, 43));
        lrb.setGyjzbdsyssyhtlSqje1(getLrbSqje(ewbhxhMap, 43));

    }

    /**
     * 包装成现金流量表实体
     * @param xjllb
     * @param nsrForm
     * @param ybqyxjllbGridlbList
     */
    public static void wrapperQykjzzybqyXjllb(SbCwbbQykjzzybqyXjllb xjllb, NsrxxForm nsrForm, List<YbqyxjllbGridlb> ybqyxjllbGridlbList) {
        Map<String, YbqyxjllbGridlb> ewbhxhMap = ybqyxjllbGridlbList.stream().collect(Collectors.toMap(YbqyxjllbGridlb::getEwbhxh, Function.identity(), (e1, e2) -> e2));
        if (nsrForm != null) {
            try {
                if (StringUtils.isNotBlank(nsrForm.getBsrq())) {
                    xjllb.setBsrq(DateUtils.parseDate(nsrForm.getBsrq(), "yyyy-MM-dd"));
                }
            } catch (ParseException e) {
                log.error("日期转换有误:" + nsrForm.getBsrq());
            }
            xjllb.setBbssq(nsrForm.getBbssq());
        }
        xjllb.setSjcjSj(new Date());

        //1     销售商品、提供劳务收到的现金
        xjllb.setXssptglwsddxjBqje(getXjllbBqje(ewbhxhMap, 1));
        xjllb.setXssptglwsddxjSqje1(getXjllbSqje(ewbhxhMap, 1));
        //2     收到的税费返还
        xjllb.setSddsffhBqje(getXjllbBqje(ewbhxhMap, 2));
        xjllb.setSddsffhSqje1(getXjllbSqje(ewbhxhMap, 2));
        //3     收到其他与经营活动有关的现金
        xjllb.setSdqtyjyhdygdxjBqje(getXjllbBqje(ewbhxhMap, 3));
        xjllb.setSdqtyjyhdygdxjSqje1(getXjllbSqje(ewbhxhMap, 3));
        //4     经营活动现金流入小计
        xjllb.setJyhdxjlrxjBqje(getXjllbBqje(ewbhxhMap, 4));
        xjllb.setJyhdxjlrxjSqje1(getXjllbSqje(ewbhxhMap, 4));
        //5     购买商品、接受劳务支付的现金
        xjllb.setGmspjslwzfdxjBqje(getXjllbBqje(ewbhxhMap, 5));
        xjllb.setGmspjslwzfdxjSqje1(getXjllbSqje(ewbhxhMap, 5));
        //6     支付给职工以及为职工支付的现金
        xjllb.setZfgzgyjwzgzfdxjBqje(getXjllbBqje(ewbhxhMap, 6));
        xjllb.setZfgzgyjwzgzfdxjSqje1(getXjllbSqje(ewbhxhMap, 6));
        //7     支付的各项税费
        xjllb.setZfdgxsfBqje(getXjllbBqje(ewbhxhMap, 7));
        xjllb.setZfdgxsfSqje1(getXjllbSqje(ewbhxhMap, 7));
        //8     支付其他与经营活动有关的现金
        xjllb.setZfqtyjyhdygdxjBqje(getXjllbBqje(ewbhxhMap, 8));
        xjllb.setZfqtyjyhdygdxjSqje1(getXjllbSqje(ewbhxhMap, 8));
        //9     经营活动现金流出小计
        xjllb.setJyhdxjlcxjBqje(getXjllbBqje(ewbhxhMap, 9));
        xjllb.setJyhdxjlcxjSqje1(getXjllbSqje(ewbhxhMap, 9));
        //10    经营活动产生的现金流量净额
        xjllb.setJyhdcsdxjlljeBqje(getXjllbBqje(ewbhxhMap, 10));
        xjllb.setJyhdcsdxjlljeSqje1(getXjllbSqje(ewbhxhMap, 10));
        //11    收回投资收到的现金
        xjllb.setShtzsddxjBqje(getXjllbBqje(ewbhxhMap, 11));
        xjllb.setShtzsddxjSqje1(getXjllbSqje(ewbhxhMap, 11));
        //12    取得投资收益收到的现金
        xjllb.setQdtzsysddxjBqje(getXjllbBqje(ewbhxhMap, 12));
        xjllb.setQdtzsysddxjSqje1(getXjllbSqje(ewbhxhMap, 12));
        //13    处置固定资产、无形资产和其他长期资产收回的现金净额
        xjllb.setCzgdzcwxzchqtcqzcshdxjjeBqje(getXjllbBqje(ewbhxhMap, 13));
        xjllb.setCzgdzcwxzchqtcqzcshdxjjeSqje1(getXjllbSqje(ewbhxhMap, 13));
        //14    处置子公司及其他营业单位收到的现金净额
        xjllb.setCzzgsjqtyydwsddxjjeBqje(getXjllbBqje(ewbhxhMap, 14));
        xjllb.setCzzgsjqtyydwsddxjjeSqje1(getXjllbSqje(ewbhxhMap, 14));
        //15    收到其他与投资活动有关的现金
        xjllb.setSdqtytzhdygdxjBqje(getXjllbBqje(ewbhxhMap, 15));
        xjllb.setSdqtytzhdygdxjSqje1(getXjllbSqje(ewbhxhMap, 15));
        //16    投资活动现金流入小计
        xjllb.setTzhdxjlrxjBqje(getXjllbBqje(ewbhxhMap, 16));
        xjllb.setTzhdxjlrxjSqje1(getXjllbSqje(ewbhxhMap, 16));
        //17    购建固定资产、无形资产和其他长期资产支付的现金
        xjllb.setGjgdzcwxzchqtcqzczfdxjBqje(getXjllbBqje(ewbhxhMap, 17));
        xjllb.setGjgdzcwxzchqtcqzczfdxjSqje1(getXjllbSqje(ewbhxhMap, 17));
        //18    投资支付的现金
        xjllb.setTzzfdxjBqje(getXjllbBqje(ewbhxhMap, 18));
        xjllb.setTzzfdxjSqje1(getXjllbSqje(ewbhxhMap, 18));
        //19    取得子公司及其他营业单位支付的现金净额
        xjllb.setQdzgsjqtyydwzfdxjjeBqje(getXjllbBqje(ewbhxhMap, 19));
        xjllb.setQdzgsjqtyydwzfdxjjeSqje1(getXjllbSqje(ewbhxhMap, 19));
        //20    支付其他与投资活动有关的现金
        xjllb.setZfqtytzhdygdxjBqje(getXjllbBqje(ewbhxhMap, 20));
        xjllb.setZfqtytzhdygdxjSqje1(getXjllbSqje(ewbhxhMap, 20));
        //21    投资活动现金流出小计
        xjllb.setTzhdxjlcxjBqje(getXjllbBqje(ewbhxhMap, 21));
        xjllb.setTzhdxjlcxjSqje1(getXjllbSqje(ewbhxhMap, 21));
        //22    投资活动产生的现金流量净额
        xjllb.setTzhdcsdxjlljeBqje(getXjllbBqje(ewbhxhMap, 22));
        xjllb.setTzhdcsdxjlljeSqje1(getXjllbSqje(ewbhxhMap, 22));
        //23    吸收投资收到的现金
        xjllb.setXstzsddxjBqje(getXjllbBqje(ewbhxhMap, 23));
        xjllb.setXstzsddxjSqje1(getXjllbSqje(ewbhxhMap, 23));
        //24    取得借款收到的现金
        xjllb.setQdjksddxjBqje(getXjllbBqje(ewbhxhMap, 24));
        xjllb.setQdjksddxjSqje1(getXjllbSqje(ewbhxhMap, 24));
        //25    收到其他与筹资活动有关的现金
        xjllb.setSdqtyczhdygdxjBqje(getXjllbBqje(ewbhxhMap, 25));
        xjllb.setSdqtyczhdygdxjSqje1(getXjllbSqje(ewbhxhMap, 25));
        //26    筹资活动现金流入小计
        xjllb.setCzhdxjlrxjBqje(getXjllbBqje(ewbhxhMap, 26));
        xjllb.setCzhdxjlrxjSqje1(getXjllbSqje(ewbhxhMap, 26));
        //27    偿还债务支付的现金
        xjllb.setChzwzfdxjBqje(getXjllbBqje(ewbhxhMap, 27));
        xjllb.setChzwzfdxjSqje1(getXjllbSqje(ewbhxhMap, 27));
        //28    分配股利、利润或偿付利息支付的现金
        xjllb.setFpgllrhcflxzfdxjBqje(getXjllbBqje(ewbhxhMap, 28));
        xjllb.setFpgllrhcflxzfdxjSqje1(getXjllbSqje(ewbhxhMap, 28));
        //29    支付其他与筹资活动有关的现金
        xjllb.setZfqtyczhdygdxjBqje(getXjllbBqje(ewbhxhMap, 29));
        xjllb.setZfqtyczhdygdxjSqje1(getXjllbSqje(ewbhxhMap, 29));
        //30    筹资活动现金流出小计
        xjllb.setCzhdxjlcxjBqje(getXjllbBqje(ewbhxhMap, 30));
        xjllb.setCzhdxjlcxjSqje1(getXjllbSqje(ewbhxhMap, 30));
        //31    筹资活动产生的现金流量净额
        xjllb.setCzhdcsdxjlljeBqje(getXjllbBqje(ewbhxhMap, 31));
        xjllb.setCzhdcsdxjlljeSqje1(getXjllbSqje(ewbhxhMap, 31));
        //32    四、汇率变动对现金及现金等价物的影响
        xjllb.setShlbddxjjxjdjwdyxBqje(getXjllbBqje(ewbhxhMap, 32));
        xjllb.setShlbddxjjxjdjwdyxSqje1(getXjllbSqje(ewbhxhMap, 32));
        //33    五、现金及现金等价物净增加额
        xjllb.setWxjjxjdjwjzjeBqje(getXjllbBqje(ewbhxhMap, 33));
        xjllb.setWxjjxjdjwjzjeSqje1(getXjllbSqje(ewbhxhMap, 33));
        //34    加:期初现金及现金等价物余额
        xjllb.setJqcxjjxjdjwyeBqje(getXjllbBqje(ewbhxhMap, 34));
        xjllb.setJqcxjjxjdjwyeSqje1(getXjllbSqje(ewbhxhMap, 34));
        //35    六、期末现金及现金等价物余额
        xjllb.setLqmxjjxjdjwyeBqje(getXjllbBqje(ewbhxhMap, 35));
        xjllb.setLqmxjjxjdjwyeSqje1(getXjllbSqje(ewbhxhMap, 35));
    }

    /**
     * 包装资产负债表数据为实体类
     * @param zcfzb
     * @param nsrForm
     * @param gridlbList
     */
    public static void wrapperQykjzzybqyZcfzb(SbCwbbQykjzzybqyZcfzb zcfzb, NsrxxForm nsrForm, List<YbqyzcfzbzbGridlb> gridlbList) {
        Map<String, YbqyzcfzbzbGridlb> ewbhxhMap = gridlbList.stream().collect(Collectors.toMap(YbqyzcfzbzbGridlb::getEwbhxh, Function.identity(), (e1, e2) -> e2));
        if (nsrForm != null) {
            try {
                if (StringUtils.isNotBlank(nsrForm.getZcfzbr())) {
                    zcfzb.setZcfzbr(DateUtils.parseDate(nsrForm.getZcfzbr(), "yyyy-MM-dd"));
                } else {
                    zcfzb.setZcfzbr(new Date());
                }
            } catch (ParseException e) {
                log.error("日期转换有误:" + nsrForm.getBsrq());
            }
            zcfzb.setBbssq(nsrForm.getBbssq());
        }
        zcfzb.setSjcjSj(new Date());

        //1 L:货币资金;R:短期借款;
        zcfzb.setHbzjQmyeZc(getZcfzbQmyeZc(ewbhxhMap,1));
        zcfzb.setHbzjNcyeZc(getZcfzbNcyeZc(ewbhxhMap, 1));
        zcfzb.setDqjkQmyeQy(getZcfzbQmyeQy(ewbhxhMap, 1));
        zcfzb.setDqjkNcyeQy(getZcfzbNcyeQy(ewbhxhMap, 1));
        //2 L:以公允价值计量且其变动计入当期损益的金融资产; R:以公允价值计量且其变动计入当期损益的金融负债;
        zcfzb.setYgyjzjlqqbdjrdqsydjrzcQmyeZc(getZcfzbQmyeZc(ewbhxhMap,2));
        zcfzb.setYgyjzjlqqbdjrdqsydjrzcNcyeZc(getZcfzbNcyeZc(ewbhxhMap, 2));
        zcfzb.setYgyjzjlqqbdjrdqsydjrfzQmyeQy(getZcfzbQmyeQy(ewbhxhMap, 2));
        zcfzb.setYgyjzjlqqbdjrdqsydjrfzNcyeQy(getZcfzbNcyeQy(ewbhxhMap, 2));
        //3 L:应收票据-资产; R:应付票据-权益;
        zcfzb.setYspjQmyeZc(getZcfzbQmyeZc(ewbhxhMap,3));
        zcfzb.setYspjNcyeZc(getZcfzbNcyeZc(ewbhxhMap, 3));
        zcfzb.setYfpjQmyeQy(getZcfzbQmyeQy(ewbhxhMap, 3));
        zcfzb.setYfpjNcyeQy(getZcfzbNcyeQy(ewbhxhMap, 3));
        //4 L:应收账款-资产; R:应付账款-权益;
        zcfzb.setYszkQmyeZc(getZcfzbQmyeZc(ewbhxhMap,4));
        zcfzb.setYszkNcyeZc(getZcfzbNcyeZc(ewbhxhMap, 4));
        zcfzb.setYfzkQmyeQy(getZcfzbQmyeQy(ewbhxhMap, 4));
        zcfzb.setYfzkNcyeQy(getZcfzbNcyeQy(ewbhxhMap, 4));
        //5 L:预付款项; R:预收款项;
        zcfzb.setYfkxQmyeZc(getZcfzbQmyeZc(ewbhxhMap,5));
        zcfzb.setYfkxNcyeZc(getZcfzbNcyeZc(ewbhxhMap, 5));
        zcfzb.setYskxQmyeQy(getZcfzbQmyeQy(ewbhxhMap, 5));
        zcfzb.setYskxNcyeQy(getZcfzbNcyeQy(ewbhxhMap, 5));
        //6 L: R:应付职工薪酬;
        zcfzb.setYfzgxcQmyeQy(getZcfzbQmyeQy(ewbhxhMap, 6));
        zcfzb.setYfzgxcNcyeQy(getZcfzbNcyeQy(ewbhxhMap, 6));
        //7 L: R:应交税费;
        zcfzb.setYjsfQmyeQy(getZcfzbQmyeQy(ewbhxhMap, 7));
        zcfzb.setYjsfNcyeQy(getZcfzbNcyeQy(ewbhxhMap, 7));
        //8 L:其他应收 R:
        zcfzb.setQtyskQmyeZc(getZcfzbQmyeZc(ewbhxhMap,8));
        zcfzb.setQtyskNcyeZc(getZcfzbNcyeZc(ewbhxhMap, 8));
        //9 L:存货 R:
        zcfzb.setChQmyeZc(getZcfzbQmyeZc(ewbhxhMap,9));
        zcfzb.setChNcyeZc(getZcfzbNcyeZc(ewbhxhMap, 9));
        //10 L:一年内到期的非流动资产 R:其他应付款
        zcfzb.setYnndqdfldzcQmyeZc(getZcfzbQmyeZc(ewbhxhMap,10));
        zcfzb.setYnndqdfldzcNcyeZc(getZcfzbNcyeZc(ewbhxhMap, 10));
        zcfzb.setQtyfkQmyeQy(getZcfzbQmyeQy(ewbhxhMap, 10));
        zcfzb.setQtyfkNcyeQy(getZcfzbNcyeQy(ewbhxhMap, 10));
        //11 L:其他流动资产 R:一年内到期的非流动负债
        zcfzb.setQtldzcQmyeZc(getZcfzbQmyeZc(ewbhxhMap,11));
        zcfzb.setQtldzcNcyeZc(getZcfzbNcyeZc(ewbhxhMap, 11));
        zcfzb.setYnndqdfldfzQmyeQy(getZcfzbQmyeQy(ewbhxhMap, 11));
        zcfzb.setYnndqdfldfzNcyeQy(getZcfzbNcyeQy(ewbhxhMap, 11));
        //12 L:流动资产合计 R:其他流动负债
        zcfzb.setLdzchjQmyeZc(getZcfzbQmyeZc(ewbhxhMap,12));
        zcfzb.setLdzchjNcyeZc(getZcfzbNcyeZc(ewbhxhMap, 12));
        zcfzb.setQtldfzQmyeQy(getZcfzbQmyeQy(ewbhxhMap, 12));
        zcfzb.setQtldfzNcyeQy(getZcfzbNcyeQy(ewbhxhMap, 12));
        //13 L: R:流动负债合计
        zcfzb.setLdfzhjQmyeQy(getZcfzbQmyeQy(ewbhxhMap, 13));
        zcfzb.setLdfzhjNcyeQy(getZcfzbNcyeQy(ewbhxhMap, 13));
        //14 L:可供出售金融资产 R:
        zcfzb.setKgcsjrzcQmyeZc(getZcfzbQmyeZc(ewbhxhMap,14));
        zcfzb.setKgcsjrzcNcyeZc(getZcfzbNcyeZc(ewbhxhMap, 14));
        //15 L:持有至到期投资 R:长期借款
        zcfzb.setCyzdqtzQmyeZc(getZcfzbQmyeZc(ewbhxhMap,15));
        zcfzb.setCyzdqtzNcyeZc(getZcfzbNcyeZc(ewbhxhMap, 15));
        zcfzb.setCqjkQmyeQy(getZcfzbQmyeQy(ewbhxhMap, 15));
        zcfzb.setCqjkNcyeQy(getZcfzbNcyeQy(ewbhxhMap, 15));
        //16 L:长期应收款 R:应付债券
        zcfzb.setCqyskQmyeZc(getZcfzbQmyeZc(ewbhxhMap,16));
        zcfzb.setCqyskNcyeZc(getZcfzbNcyeZc(ewbhxhMap, 16));
        zcfzb.setYfzqQmyeQy(getZcfzbQmyeQy(ewbhxhMap, 16));
        zcfzb.setYfzqNcyeQy(getZcfzbNcyeQy(ewbhxhMap, 16));
        //17 L:长期股权投资 R:长期应付款
        zcfzb.setCqgqtzQmyeZc(getZcfzbQmyeZc(ewbhxhMap,17));
        zcfzb.setCqgqtzNcyeZc(getZcfzbNcyeZc(ewbhxhMap, 17));
        zcfzb.setCqyfkQmyeQy(getZcfzbQmyeQy(ewbhxhMap, 17));
        zcfzb.setCqyfkNcyeQy(getZcfzbNcyeQy(ewbhxhMap, 17));
        //18 L:投资性房地产 R:
        zcfzb.setTzxfdcQmyeZc(getZcfzbQmyeZc(ewbhxhMap,18));
        zcfzb.setTzxfdcNcyeZc(getZcfzbNcyeZc(ewbhxhMap, 18));
        //19 L:固定资产 R:预计负债
        zcfzb.setGdzcQmyeZc(getZcfzbQmyeZc(ewbhxhMap,19));
        zcfzb.setGdzcNcyeZc(getZcfzbNcyeZc(ewbhxhMap, 19));
        zcfzb.setYjfzQmyeQy(getZcfzbQmyeQy(ewbhxhMap, 19));
        zcfzb.setYjfzNcyeQy(getZcfzbNcyeQy(ewbhxhMap, 19));
        //20 L:在建工程 R:递延所得税负债
        zcfzb.setZjgcQmyeZc(getZcfzbQmyeZc(ewbhxhMap,20));
        zcfzb.setZjgcNcyeZc(getZcfzbNcyeZc(ewbhxhMap, 20));
        zcfzb.setDysdsfzQmyeQy(getZcfzbQmyeQy(ewbhxhMap, 20));
        zcfzb.setDysdsfzNcyeQy(getZcfzbNcyeQy(ewbhxhMap, 20));
        //21 L: R:其他非流动负债
        zcfzb.setQtfldfzQmyeQy(getZcfzbQmyeQy(ewbhxhMap, 21));
        zcfzb.setQtfldfzNcyeQy(getZcfzbNcyeQy(ewbhxhMap, 21));
        //22 L: R:非流动负债合计
        zcfzb.setFldfzhjQmyeQy(getZcfzbQmyeQy(ewbhxhMap, 22));
        zcfzb.setFldfzhjNcyeQy(getZcfzbNcyeQy(ewbhxhMap, 22));
        //23 L:生产性生物资产 R:负债合计
        zcfzb.setScxswzcQmyeZc(getZcfzbQmyeZc(ewbhxhMap,23));
        zcfzb.setScxswzcNcyeZc(getZcfzbNcyeZc(ewbhxhMap, 23));
        zcfzb.setFzhjQmyeQy(getZcfzbQmyeQy(ewbhxhMap, 23));
        zcfzb.setFzhjNcyeQy(getZcfzbNcyeQy(ewbhxhMap, 23));
        //24 L:油气资产 R:
        zcfzb.setYqzcQmyeZc(getZcfzbQmyeZc(ewbhxhMap,24));
        zcfzb.setYqzcNcyeZc(getZcfzbNcyeZc(ewbhxhMap, 24));
        //25 L:无形资产 R:实收资本（或股本）
        zcfzb.setWxzcQmyeZc(getZcfzbQmyeZc(ewbhxhMap,25));
        zcfzb.setWxzcNcyeZc(getZcfzbNcyeZc(ewbhxhMap, 25));
        zcfzb.setSszbhgbQmyeQy(getZcfzbQmyeQy(ewbhxhMap, 25));
        zcfzb.setSszbhgbNcyeQy(getZcfzbNcyeQy(ewbhxhMap, 25));
        //26 L:开发支出 R:资本公积
        zcfzb.setKfzcQmyeZc(getZcfzbQmyeZc(ewbhxhMap,26));
        zcfzb.setKfzcNcyeZc(getZcfzbNcyeZc(ewbhxhMap, 26));
        zcfzb.setZbgjQmyeQy(getZcfzbQmyeQy(ewbhxhMap, 26));
        zcfzb.setZbgjNcyeQy(getZcfzbNcyeQy(ewbhxhMap, 26));
        //27 L:商誉 R:减：库存股
        zcfzb.setSyQmyeZc(getZcfzbQmyeZc(ewbhxhMap,27));
        zcfzb.setSyNcyeZc(getZcfzbNcyeZc(ewbhxhMap, 27));
        zcfzb.setJkcgQmyeQy(getZcfzbQmyeQy(ewbhxhMap, 27));
        zcfzb.setJkcgNcyeQy(getZcfzbNcyeQy(ewbhxhMap, 27));
        //28 L:长期待摊费用 R:盈余公积
        zcfzb.setCqdtfyQmyeZc(getZcfzbQmyeZc(ewbhxhMap,28));
        zcfzb.setCqdtfyNcyeZc(getZcfzbNcyeZc(ewbhxhMap, 28));
        zcfzb.setYygjQmyeQy(getZcfzbQmyeQy(ewbhxhMap, 28));
        zcfzb.setYygjNcyeQy(getZcfzbNcyeQy(ewbhxhMap, 28));
        //29 L:递延所得税资产 R:未分配利润
        zcfzb.setDysdszcQmyeZc(getZcfzbQmyeZc(ewbhxhMap,29));
        zcfzb.setDysdszcNcyeZc(getZcfzbNcyeZc(ewbhxhMap, 29));
        zcfzb.setWfplrQmyeQy(getZcfzbQmyeQy(ewbhxhMap, 29));
        zcfzb.setWfplrNcyeQy(getZcfzbNcyeQy(ewbhxhMap, 29));
        //30 L:其他非流动资产 R:所有者权益（或股东权益）合计
        zcfzb.setQtfldzcQmyeZc(getZcfzbQmyeZc(ewbhxhMap,30));
        zcfzb.setQtfldzcNcyeZc(getZcfzbNcyeZc(ewbhxhMap, 30));
        zcfzb.setSyzqyhgdqyhjQmyeQy(getZcfzbQmyeQy(ewbhxhMap, 30));
        zcfzb.setSyzqyhgdqyhjNcyeQy(getZcfzbNcyeQy(ewbhxhMap, 30));
        //31 L:非流动资产合计 R:
        zcfzb.setFldzchjQmyeZc(getZcfzbQmyeZc(ewbhxhMap,31));
        zcfzb.setFldzchjNcyeZc(getZcfzbNcyeZc(ewbhxhMap, 31));
        //32 L:资产总计 R:负债和所有者权益（或股东权益）总计
        zcfzb.setZchjQmyeZc(getZcfzbQmyeZc(ewbhxhMap,32));
        zcfzb.setZchjNcyeZc(getZcfzbNcyeZc(ewbhxhMap, 32));
        zcfzb.setFzhsyzqyhgdqyzjQmyeQy(getZcfzbQmyeQy(ewbhxhMap, 32));
        zcfzb.setFzhsyzqyhgdqyzjNcyeQy(getZcfzbNcyeQy(ewbhxhMap, 32));
        //33 L: R:递延收益
        zcfzb.setDysyQmyeQy(getZcfzbQmyeQy(ewbhxhMap, 33));
        zcfzb.setDysyNcyeQy(getZcfzbNcyeQy(ewbhxhMap, 33));
        //34 L: R:其他综合收益
        zcfzb.setQtzhsyQmyeQy(getZcfzbQmyeQy(ewbhxhMap, 34));
        zcfzb.setQtzhsyNcyeQy(getZcfzbNcyeQy(ewbhxhMap, 34));
        //35 L:衍生金融资产 R:衍生金融负债
        zcfzb.setYsjrzcQmyeZc(getZcfzbQmyeZc(ewbhxhMap,35));
        zcfzb.setYsjrzcNcyeZc(getZcfzbNcyeZc(ewbhxhMap, 35));
        zcfzb.setYsjrfzQmyeQy(getZcfzbQmyeQy(ewbhxhMap, 35));
        zcfzb.setYsjrfzNcyeQy(getZcfzbNcyeQy(ewbhxhMap, 35));
        //36 L:持有待售资产 R:持有待售负债
        zcfzb.setCydszcQmyeZc(getZcfzbQmyeZc(ewbhxhMap,36));
        zcfzb.setCydszcNcyeZc(getZcfzbNcyeZc(ewbhxhMap, 36));
        zcfzb.setCydsfzQmyeQy(getZcfzbQmyeQy(ewbhxhMap, 36));
        zcfzb.setCydsfzNcyeQy(getZcfzbNcyeQy(ewbhxhMap, 36));
        //37 L: R:其中：优先股
        zcfzb.setQzyxgQmyeQy(getZcfzbQmyeQy(ewbhxhMap, 37));
        zcfzb.setQzyxgNcyeQy(getZcfzbNcyeQy(ewbhxhMap, 37));
        //38 L: R:永续债
        zcfzb.setYxzQmyeQy(getZcfzbQmyeQy(ewbhxhMap, 38));
        zcfzb.setYxzNcyeQy(getZcfzbNcyeQy(ewbhxhMap, 38));
        //39 L: R:其他权益工具
        zcfzb.setQtqygjQmyeQy(getZcfzbQmyeQy(ewbhxhMap, 39));
        zcfzb.setQtqygjNcyeQy(getZcfzbNcyeQy(ewbhxhMap, 39));
        //40 L: R:其他：优先股
        zcfzb.setQtqzyxgQmyeQy(getZcfzbQmyeQy(ewbhxhMap, 40));
        zcfzb.setQtqzyxgNcyeQy(getZcfzbNcyeQy(ewbhxhMap, 40));
        //41 L: R:永续债(其他永续债？)
        zcfzb.setQtyxzQmyeQy(getZcfzbQmyeQy(ewbhxhMap, 41));
        zcfzb.setQtyxzNcyeQy(getZcfzbNcyeQy(ewbhxhMap, 41));
        //42 L: R:专项储备
        zcfzb.setZxcbQmyeQy(getZcfzbQmyeQy(ewbhxhMap, 42));
        zcfzb.setZxcbNcyeQy(getZcfzbNcyeQy(ewbhxhMap, 42));
    }

    /**
     * 利润表-本期金额
     */
    public static Double getLrbBqje(Map<String, YbqylrbGridlb> ewbhxhMap, int rowNumber) {
        if (ewbhxhMap.get(rowNumber + "") == null) {
            return new Double(0);
        }
        YbqylrbGridlb row = ewbhxhMap.get(rowNumber + "");
        try {
            return Double.parseDouble(row.getBqje());
        } catch (Exception e) {
            if (e instanceof NullPointerException) {
                log.error("利润表第{}行数据没有Bqje,请核对报文是否准确:{}", rowNumber, JSON.toJSONString(row));
            }
            return new Double(0);
        }
    }
    /**
     * 利润表-上期金额
     */
    public static Double getLrbSqje(Map<String, YbqylrbGridlb> ewbhxhMap, int rowNumber) {
        if (ewbhxhMap.get(rowNumber + "") == null) {
            return new Double(0);
        }
        YbqylrbGridlb row = ewbhxhMap.get(rowNumber + "");
        try {
            return Double.parseDouble(row.getSqje1());
        } catch (Exception e) {
            if (e instanceof NullPointerException) {
                log.error("利润表第{}行数据没有Sqje1,请核对报文是否准确:{}", rowNumber, JSON.toJSONString(row));
            }
            return new Double(0);
        }
    }

    /**
     * 现金流量表-本期金额
     */
    public static Double getXjllbBqje(Map<String, YbqyxjllbGridlb> ewbhxhMap, int rowNumber) {
        if (ewbhxhMap.get(rowNumber + "") == null) {
            return new Double(0);
        }
        YbqyxjllbGridlb row = ewbhxhMap.get(rowNumber + "");
        try {
            return Double.parseDouble(row.getBqje());
        } catch (Exception e) {
            if (e instanceof NullPointerException) {
                log.error("现金流量表第{}行数据没有Bqje,请核对报文是否准确:{}", rowNumber, JSON.toJSONString(row));
            }
            return new Double(0);
        }
    }

    /**
     * 现金流量表-上期金额
     */
    public static Double getXjllbSqje(Map<String, YbqyxjllbGridlb> ewbhxhMap, int rowNumber) {
        if (ewbhxhMap.get(rowNumber + "") == null) {
            return new Double(0);
        }
        YbqyxjllbGridlb row = ewbhxhMap.get(rowNumber + "");
        try {
            return Double.parseDouble(row.getSqje1());
        } catch (Exception e) {
            if (e instanceof NullPointerException) {
                log.error("现金流量表第{}行数据没有SqJe1,请核对报文是否准确:{}", rowNumber, JSON.toJSONString(row));
            }
            return new Double(0);
        }
    }

    /**
     * 资产负债表-期末余额资产
     * @param ewbhxhMap
     * @param rowNumber
     * @return
     */
    public static Double getZcfzbQmyeZc(Map<String, YbqyzcfzbzbGridlb> ewbhxhMap, int rowNumber) {
        if (ewbhxhMap.get(rowNumber + "") == null) {
            return new Double(0);
        }
        YbqyzcfzbzbGridlb row = ewbhxhMap.get(rowNumber + "");
        try {
            return Double.parseDouble(row.getQmyeZc());
        } catch (Exception e) {
            if (e instanceof NullPointerException) {
                log.error("资产负债表第{}行数据没有QmsZc,请核对报文是否准确:{}", rowNumber, JSON.toJSONString(row));
            }
            return new Double(0);
        }
    }

    /**
     * 资产负债表-年初余额资产
     * @param ewbhxhMap
     * @param rowNumber
     * @return
     */
    public static Double getZcfzbNcyeZc(Map<String, YbqyzcfzbzbGridlb> ewbhxhMap, int rowNumber) {
        if (ewbhxhMap.get(rowNumber + "") == null) {
            return new Double(0);
        }
        YbqyzcfzbzbGridlb row = ewbhxhMap.get(rowNumber + "");
        try {
            return Double.parseDouble(row.getNcyeZc());
        } catch (Exception e) {
            if (e instanceof NullPointerException) {
                log.error("资产负债表第{}行数据没有NcyeZc,请核对报文是否准确:{}", rowNumber, JSON.toJSONString(row));
            }
            return new Double(0);
        }
    }

    /**
     * 资产负债表-期末余额权益
     * @param ewbhxhMap
     * @param rowNumber
     * @return
     */
    public static Double getZcfzbQmyeQy(Map<String, YbqyzcfzbzbGridlb> ewbhxhMap, int rowNumber) {
        if (ewbhxhMap.get(rowNumber + "") == null) {
            return new Double(0);
        }
        YbqyzcfzbzbGridlb row = ewbhxhMap.get(rowNumber + "");
        try {
            return Double.parseDouble(row.getQmyeQy());
        } catch (Exception e) {
            if (e instanceof NullPointerException) {
                log.error("资产负债表第{}行数据没有QmyeQy,请核对报文是否准确:{}", rowNumber, JSON.toJSONString(row));
            }
            return new Double(0);
        }
    }

    /**
     * 资产负债表-年初余额权益
     * @param ewbhxhMap
     * @param rowNumber
     * @return
     */
    public static Double getZcfzbNcyeQy(Map<String, YbqyzcfzbzbGridlb> ewbhxhMap, int rowNumber) {
        if (ewbhxhMap.get(rowNumber + "") == null) {
            return new Double(0);
        }
        YbqyzcfzbzbGridlb row = ewbhxhMap.get(rowNumber + "");
        try {
            return Double.parseDouble(row.getNcyeQy());
        } catch (Exception e) {
            if (e instanceof NullPointerException) {
                log.error("资产负债表第{}行数据没有NcyeQy,请核对报文是否准确:{}", rowNumber, JSON.toJSONString(row));
            }
            return new Double(0);
        }
    }
}
